from django.urls import path, include
from django.contrib import admin
from . import views
from .admin import CategoryAdmin

app_name = 'ebay'

urlpatterns = [
    # API接口
    path('api/categories/', views.CategoryListView.as_view(), name='category-list'),
    path('api/categories/<str:category_id>/', views.CategoryDetailView.as_view(), name='category-detail'),
    path('api/products/', views.ProductListView.as_view(), name='product-list'),
    path('api/products/<str:item_id>/', views.ProductDetailView.as_view(), name='product-detail'),
    
    # 同步接口
    path('api/sync/categories/', views.SyncCategoriesView.as_view(), name='sync-categories'),
    path('api/sync/products/<str:category_id>/', views.SyncProductsView.as_view(), name='sync-products'),
    
    # 管理页面URL
    path('category/sync_categories/', CategoryAdmin.sync_categories, name='ebay_sync_categories'),
    path('category/sync_products/<str:category_id>/', CategoryAdmin.sync_products, name='ebay_sync_products'),
    path('category/check_token/', CategoryAdmin.check_token, name='ebay_check_token'),
    path('category/get_token/', CategoryAdmin.get_token, name='ebay_get_token'),

    path('', views.product_list, name='product_list'),
    path('products/', views.product_list, name='product_list'),
    path('api/subcategories/', views.get_subcategories, name='get_subcategories'),
]
